home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 January: Mac OS SDK / Dev.CD Jan 98 SDK2.toast / Development Kits (Disc 2) / QuickDraw GX / Programming Stuff / Sample Code / Printing Samples / Printer Drivers… / Scanning Generic LaserWriter / The Approach-- Scanning < prev   
Encoding:
Text File  |  1996-03-20  |  2.5 KB  |  61 lines  |  [TEXT/MPS ]

  1. A brief description of the "Scanning Generic LaserWriter" code.
  2.  
  3. Messages overridden:
  4.  
  5. Overrides for our custom scanning support
  6. -----------------------------------------
  7. gxPostScriptScanPrinterText - Override to pre-scan text returned by GXGetPrinterText.
  8. gxPostScriptScanStatusText    - Override to pre-scan text returned by GXGetStatusText.
  9. gxOpenConnection            - Override to store class/instance context data.
  10. gxCleanupOpenConnection        - Override to remove class/instance context data.
  11. gxCloseConnection            - Override to remove class/instance context data.
  12.  
  13.  
  14. What this code does:
  15. --------------------
  16. This PS driver has code to completely handle processing of GX's
  17. 'scan' resources.  This means that you can intercept and post
  18. warnings that the default behavior doesn't know about.  For
  19. example "Magenta ink is low," "The printer needs attention,"
  20. etc.  To handle this, both gxPostScriptScanPrinterText and
  21. gxPostScriptScanStatusText are overridden.  These overrides
  22. will be either total or partial depending on what happens when
  23. we "pre-process" the text to be scanned.  If we post an alert
  24. or write to the desktop printer window, we don't forward the
  25. message to GX's default implementation.  If we did so, it might
  26. clear our messages.  However, if we simply munge the text we're
  27. passed, and don't post a message, then we forward the text to
  28. GX's default scanning code for secondary processing.
  29.  
  30.  
  31. Interesting tricks and tidbits:
  32. -------------------------------
  33. Because it's important to know what the current alert state is,
  34. we save this information in our context instance.  That way, we
  35. can easily see what the last status we processed was.  We also
  36. store the two pre-scan 'scan' handles in our class context.  This
  37. way, no matter how many instanciations of our driver are active
  38. at once, (e.g. if multiple desktop printers are printing), the
  39. 'scan' handles will only be loaded into memory once.
  40.  
  41. The process this code goes through is quite simple:
  42.  
  43.     while (there are more 'scan' entries)
  44.     {
  45.         Parse a scan entry.
  46.         Apply it to the text we're scanning, using Munger.
  47.         Hold on to the most urgent alert (if any) that
  48.         should be posted as a result of matches between
  49.         'scan' entries and the text we're looking at.
  50.     }
  51.         
  52.     If (the most urgent alert condition we found was "Normal status")
  53.         Clear any alert condition that we posted.
  54.     else
  55.         If (the most urgent alert condition we found was a non-fatal error)
  56.             Post it using GXAlertTheUser.
  57.         else
  58.             If (the most urgent alert condition we found was a fatal error)
  59.                 return the error.
  60.  
  61. dmh 7/4/94